package com.itc.bi.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itc.bi.entity.TableColumnEntity;
import com.itc.bi.query.TableColumnQuery;
import com.itc.bi.service.TableColumnService;
import com.itc.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@Api(value = "字段信息",tags = "数据库连接表字段")
@RequestMapping("/tableColumn")
public class TableColumnController {

    @Autowired
    TableColumnService service;

    @GetMapping("/get/{id}")
    @ApiOperation(value = "根据ID获取数据")
    public R<TableColumnEntity> get(@PathVariable("id") Long id){
        TableColumnEntity entity = service.getById(id);
        if(null == entity){
            return R.fail("获取数据失败，记录不存在");
        }
        return R.ok(entity);
    }

    @PostMapping("/page")
    @ApiOperation(value = "列表-分页")
    public R<Page> Page(@RequestBody TableColumnQuery query){
        return R.ok(service.page(query));
    }

    @PostMapping("/list")
    @ApiOperation(value = "列表")
    public R<List<TableColumnEntity>> list(@RequestBody TableColumnQuery query){
        return R.ok(service.list(query));
    }
}
